<template>
<h1>猜数字练习</h1>
  <input type="text" v-model="request">
  <button @click = 'guess()'>Guess</button>
  <p>{{result}}</p>
  <p>{{randomNum}}</p>
</template>

<script setup>
import {ref} from "vue";

const randomNum =ref('');
const request = ref('');
const result = ref('');

//生成随机数
randomNum.value = parseInt(Math.random()*100)+1;

const guess = () => {
  if(randomNum.value == request.value){
    result.value = '猜对了';
  }else{
    result.value = '猜错了';
  }
}
console.log(randomNum.value);
</script>

<style scoped>

</style>